package com.tfjybj.itoo.exam.provider.service.impl;

import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.exam.entity.ChangeQuestionEntity;
import com.tfjybj.itoo.exam.model.ChangeQuestionModel;
import com.tfjybj.itoo.exam.provider.dao.ChangeQuestionDao;
import com.tfjybj.itoo.exam.provider.service.ChangeQuestionService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * ChangeQuestionService接口实现类
 * ${base}表
 *
 * @author 贾建清
 * @version 2.0.0
 * @since 2.0.0 2018-12-30 09:44:46
 */
@Service("changeQuestionService")
public class ChangeQuestionServiceImpl extends BaseServicePlusImpl<ChangeQuestionDao, ChangeQuestionEntity> implements ChangeQuestionService {

    //region 模板生成
    @Resource
    private ChangeQuestionDao changeQuestionDao;

    //endregion

    /* **********************************以下为非模板生成的内容********************************* */

    /**
     * 根据旧题id搜索修改试题信息
     *
     * @param content
     * @param pageNo   页码
     * @param pageSize 页数
     * @return ItooResult
     * @author 贾建清
     * @since 2.0.0 2018-12-30 10:47:52
     */
    @Override
    public PageInfo<ChangeQuestionModel> queryChangeQuestionByLikeContent(String content, String operator, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<ChangeQuestionModel> changeQuestionModelList = changeQuestionDao.queryChangeQuestionByLikeContent(content, operator);
        return new PageInfo<>(changeQuestionModelList);
    }

    /**
     * 将当前考试抽到错题的考生插入到表中
     *
     * @param changeQuestionModel 单个考生的
     * @return 布尔值
     * @author 任蒙蒙
     */
    @Override
    public boolean insertExamineeForWrongQuestion(ChangeQuestionModel changeQuestionModel) {
        ChangeQuestionEntity changeQuestionEntity = new ChangeQuestionEntity();
        BeanUtils.copyProperties(changeQuestionModel, changeQuestionEntity);
        return this.save(changeQuestionEntity);
    }

}
